<template>
    <div class="manage1">
        <el-form :inline="true" class="manage1_from1">
            <el-form-item label=""></el-form-item>
            <el-form-item label="球种：">
                <el-select v-model="param.ballSeed" @change="schoolCge" placeholder="足球,篮球,曲棍球,排球,羽毛球,乒乓球,网球,橄榄球,其他"
                    clearable class="manage1_from1_select1">
                    <el-option key="1" label="足球" value="足球" />
                    <el-option key="2" label="篮球" value="篮球" />
                    <el-option key="3" label="曲棍球" value="曲棍球" />
                    <el-option key="4" label="排球" value="排球" />
                    <el-option key="5" label="羽毛球" value="羽毛球" />
                    <el-option key="6" label="乒乓球" value="乒乓球" />
                    <el-option key="7" label="网球" value="网球" />
                    <el-option key="8" label="橄榄球" value="橄榄球" />
                    <el-option key="9" label="其他" value="其他" />
                </el-select>
            </el-form-item>


            <el-form-item label="赛事名称：">
                <el-input v-model="param.title" placeholder="赛事名称" clearable class="manage1_from1_input1" />
            </el-form-item>


            <!-- <el-form-item label="状态：">
               <el-select v-model="param.status" @change="schoolCge" placeholder="未开始,进行中,已完成" clearable
                          class="manage1_from1_select1">
                    <el-option key="1" label="未开始" value="1" />
                    <el-option key="2" label="进行中" value="2" />
                    <el-option key="3" label="已完成" value="3" />
               </el-select>
           </el-form-item> -->
            <el-form-item label="城市：">
                <el-input v-model="param.city" placeholder="城市" clearable class="manage1_from1_input1" />
            </el-form-item>

            <!-- <el-form-item label="开赛时间：">
               <el-date-picker v-model="param.startTime" type="date" class="manage1_from1_time1" placeholder="开始时间"
                               format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable /> &nbsp; 至 &nbsp;
               <el-date-picker v-model="param.endTime" type="date" class="manage1_from1_time1" placeholder="结束时间"
                               format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable />
           </el-form-item> <br />


           <el-form-item label="报名开始时间：">
               <el-date-picker v-model="param.startTime" type="date" class="manage1_from1_time1" placeholder="开始时间"
                               format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable /> &nbsp; 至 &nbsp;
               <el-date-picker v-model="param.endTime" type="date" class="manage1_from1_time1" placeholder="结束时间"
                               format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable />
           </el-form-item> <br /> -->


            <el-form-item label="赛事类型：">
                <el-select v-model="param.type" @change="schoolCge" placeholder="官方赛,友谊赛,群众赛" clearable
                    class="manage1_from1_select1">
                    <el-option key="1" label="官方赛" value="1" />
                    <el-option key="2" label="友谊赛" value="3" />
                    <el-option key="3" label="群众赛" value="2" />
                </el-select>
            </el-form-item>


            <el-form-item label="赛制：">
                <el-select v-model="param.format" @change="schoolCge" placeholder="杯赛,联赛,友谊赛" clearable
                    class="manage1_from1_select1">
                    <el-option key="1" label="杯赛" value="1" />
                    <el-option key="2" label="联赛" value="2" />
                    <el-option key="3" label="友谊赛" value="0" />
                </el-select>
            </el-form-item>


            <el-form-item label="人员类型：">
                <el-select v-model="param.personnelType" @change="schoolCge"
                    placeholder="1人制,2人制,3人制,4人制,5人制,6人制,7人制,8人制,9人制,10人制,11人制" clearable class="manage1_from1_select1">
                    <el-option key="1" label="1人制" value="1人制" />
                    <el-option key="2" label="2人制" value="2人制" />
                    <el-option key="3" label="3人制" value="3人制" />
                    <el-option key="4" label="4人制" value="4人制" />
                    <el-option key="5" label="5人制" value="5人制" />
                    <el-option key="6" label="6人制" value="6人制" />
                    <el-option key="7" label="7人制" value="7人制" />
                    <el-option key="8" label="8人制" value="8人制" />
                    <el-option key="9" label="9人制" value="9人制" />
                    <el-option key="10" label="10人制" value="10人制" />
                    <el-option key="11" label="11人制" value="11人制" />
                </el-select>
            </el-form-item>


            <el-form-item label="参赛年龄：">
                <el-select v-model="param.age" @change="schoolCge" placeholder="成人,青少年" clearable
                    class="manage1_from1_select1">
                    <el-option key="1" label="青少年" value="1" />
                    <el-option key="2" label="成人" value="2" />
                </el-select>
            </el-form-item>


            <el-form-item>
                <el-button type="primary" class="manage1_from1_button1" @click="getList(1)">搜索</el-button>
                <el-button @click="rewrite" text type="primary">
                    <el-icon :size="16">
                        <refresh />
                    </el-icon> &nbsp;重置筛选条件
                </el-button>
            </el-form-item>
        </el-form>
    </div>
    <div class="list1" v-if="param.tablestatus == 1" v-loading="loading">
        <el-table ref="selectTable" :data="list1">
            <el-table-column prop="matchId" min-width="120" label="id"></el-table-column>

            <el-table-column prop="title" min-width="120" label="赛事名称"></el-table-column>

            <el-table-column min-width="80" label="是否官方">
                <template #default="scope">
                    {{ type[scope.row.type] }}
                </template>
            </el-table-column>

            <el-table-column prop="city" min-width="120" label="城市"></el-table-column>
            <el-table-column prop="ballSeed" min-width="120" label="球种"></el-table-column>

            <el-table-column min-width="80" label="赛制">
                <template #default="scope">
                    {{ format[scope.row.format] }}
                </template>
            </el-table-column>
            <el-table-column prop="personnelType" min-width="120" label="人员类型"></el-table-column>

            <el-table-column min-width="80" label="参赛年龄">
                <template #default="scope">
                    {{ age[scope.row.age] }}
                </template>
            </el-table-column>

            <el-table-column min-width="80" label="赛事类型">
                <template #default="scope">
                    {{ type[scope.row.type] }}
                </template>
            </el-table-column>

            <!-- <el-table-column prop="startTime" min-width="120" label="报名开始时间"></el-table-column>

                            <el-table-column prop="endTime" min-width="120" label="赛事开始时间"></el-table-column> -->

            <!-- <el-table-column min-width="80" label="状态" >
                                <template #default="scope">
                                    {{status[scope.row.status]}}
                                </template>
                            </el-table-column> -->

            <el-table-column prop="nickname" min-width="120" label="创建人"></el-table-column>
            <el-table-column prop="createTime" min-width="120" label="创建时间"></el-table-column>

            <el-table-column fixed="right" label="操作" min-width="200">
                <template #default="scope">
                    <div class="list1_operate1">
                        <el-button @click="$router.push('/saishixiangqingnwe/' + scope.row.matchId)" text
                            type="primary">详情</el-button>
                        <!-- <el-divider class="list1_operate1_line1" direction="vertical" /> -->
                        <!-- <el-button @click="tanchuang1(scope.row,0)"  text type="primary">删除</el-button>
                      <el-divider class="list1_operate1_line1" direction="vertical" /> -->
                    </div>
                </template>
            </el-table-column>
        </el-table>


        <div class="list1_page1">
            <p class="list1_page1_title1">共 {{ total }} 条</p>
            <el-pagination v-model:currentPage="param.pageNumber" @size-change="handleSizeChange"
                @current-change="handleCurrentChange" :page-sizes="[10, 15, 20, 25]" :page-size="param.pageSize"
                layout=" sizes, prev , jumper , next" :total="total">
            </el-pagination>
        </div>
    </div>


</template>
<script>

export default {
    data() {
        return {
            param: {},
            list1: [],

            param: {
                pageNumber: 1,
                pageSize: 10,
                tablestatus: 1,
            },
            loading: false,
            total: 0,
            age: { 1: '青少年', 2: '成人' },
            format: { 1: '杯赛', 2: '联赛', 0: '友谊赛' },
            status: { 1: '开放报名', 2: '进行中', 3: '已结束' },
            type: { 1: '官方赛事', 2: '群众赛事', 3: '友谊赛' },
        }
    },

    created() {
        this.getList()
    },

    mounted() {
    },

    components: {
    },

    methods: {
        rewrite() {
            let that = this;
            let obj = {
                pageNumber: that.param.pageNumber,
                pageSize: that.param.pageSize,
                tablestatus: that.param.tablestatus
            }
            that.param = obj;
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.param.pageSize = val;
            this.getList();
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.param.pageNumber = val;
            this.getList();
        },

        tanchuang1(val, status) {
            let that = this;
            this.$msgbox.confirm(
                " ",
                "已删除",
                {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                }
            ).then(() => {
                this.$api.removedd({ matchId: val.matchId }).then(res => {
                    console.log(res);
                    if (res) {
                        that.getList();
                        that.$message.success(res.message);
                    }
                })
            }).catch(() => { });
        },


        getList(pageNumber) {
            this.loading = true;
            let res;
            if (pageNumber) {
                this.param.pageNumber = pageNumber;
            }
            this.$api.competitionlist(this.param).then(res => {
                console.log('res====', res)
                if (res) {
                    let url = 'list' + this.param.tablestatus
                    this[url] = res.records
                    this.total = res.total;
                }
            })
            this.loading = false;
        },


    }

}


</script>
<style lang="scss" scoped>
.manage1 {
    padding: 10px 20px 10px;
    background-color: #fff;
    text-align: left;

    .manage1_from1 {
        background: #F2F3F5;
        padding: 24px 16px 4px;
        text-align: left;

        .manage1_from1_input1 {
            width: 250px
        }

        .manage1_from1_input2 {
            width: 110px;
            margin-right: 10px;
        }

        .manage1_from1_input3 {
            width: 110px;
            margin-left: 10px;
        }

        .manage1_from1_select1 {
            width: 250px
        }

        .manage1_from1_time1 {
            width: 110px
        }

        .manage1_from1_button1 {
            width: 115px;
        }
    }

}

.list1 {
    background-color: #fff;

    .list1_head1 {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }

    .list1_operate1 {
        width: 100%;
        display: flex;
        justify-content: center;

        .list1_operate1_line1 {
            margin: auto 10px;
        }
    }

    .list1_page1 {
        height: 70px;
        padding: 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;

        .list1_page1_title1 {
            font-size: 10px;
            color: #A4A4A4;
        }
    }
}
</style>